# -*- coding: utf-8 -*-
__author__ = 'BuddyHolly'

import os
import zipfile


# =============================
# *** 压缩图片为ZIP ***
#
# dirpath：压缩内容路径
# outFullName：ZIP存取路径及文件名
#
# zip存储至outFullName，无返回值
# =============================

def zip_pic(dirpath, outFullName):
    tmp_zip = zipfile.ZipFile(outFullName, "w", zipfile.ZIP_DEFLATED)
    for path, dirnames, filenames in os.walk(dirpath):
        fpath = path.replace(dirpath, '')
        for filename in filenames:
            tmp_zip.write(os.path.join(path, filename), os.path.join(fpath, filename))
    tmp_zip.close()
